package cn.itcast.nems.journal.service.impl;

import cn.itcast.nems.journal.api.JournalRenewalLineDiscountApi;
import cn.itcast.nems.journal.service.JournalRenewalLineDiscountService;
import cn.itcast.nems.studentrecord.constant.DiscountScopeTypeEnum;
import cn.itcast.nems.studentrecord.dao.entity.JournalRenewalLineDiscount;
import cn.itcast.nems.studentrecord.dao.mapper.JournalRenewalLineDiscountMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class JournalRenewalLineDiscountServiceImpl
        extends ServiceImpl<JournalRenewalLineDiscountMapper, JournalRenewalLineDiscount>
        implements JournalRenewalLineDiscountService, JournalRenewalLineDiscountApi {

    public List<String> findListByRenewalIdAndLineId(String renewalId, String lineId) {
        return this.listObjs(new LambdaQueryWrapper<JournalRenewalLineDiscount>()
                        .select(JournalRenewalLineDiscount::getJournalDiscountLineId)
                        .eq(JournalRenewalLineDiscount::getJournalRenewalId, renewalId)
                        .eq(JournalRenewalLineDiscount::getJournalRenewalLineId, lineId)
                        .eq(JournalRenewalLineDiscount::getDiscountScopeType, DiscountScopeTypeEnum.PERSONAL.name()),
                Object::toString
        );
    }
}
